/* pipdisconnect.c - pipdisconnect */

#include <xinu.h>
#include <mips.h>

syscall   pipdisconnect(
		pipid32         pipid             /* ID of pipe to connect   */
        )
{
	intmask mask;                   /* saved interrupt mask         */
	struct pipent *piptr;		/* ptr to pipe's table entry	*/

	mask = disable();		/* saved interrupt mask         */

	if (isbadpipid(pipid) || (piptr->pistate != PIPE_CONNECTED)) {
                restore(mask);
                return SYSERR;
        }

	piptr = &piptab[pipid];

	piptr->pistate = PIPE_USED;
	restore(mask);
	return pipid;
}
